﻿using AutoMapper;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S_Gridding.Api.Application.Commands.AssemType;

namespace S_Gridding.Api.Controllers
{
    /// <summary>
    /// 部件类型控制器
    /// </summary>

    [Route("api/[controller]/[action]")]
    [ApiController]
    // [ApiExplorerSettings(GroupName = nameof(ApiVersionInfo.部件类型))]
    [ApiExplorerSettings(GroupName =nameof(ApiVersionInfo.部件类型))]
    public class AssemTypeController : ControllerBase
    {
        private readonly IMediator _mediator;  //注入中介者

        public AssemTypeController(IMediator mediator)
        {
            _mediator = mediator;
        }

        [HttpGet]
        public string FourNomalSend()
        {
            return "Testwords";
        }


        /// <summary>
        /// 添加部件类型信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddAssemTypeInfo(AssemTypeCreateCommand m)
        {
            return await _mediator.Send(m);
        }

        /// <summary>
        /// 修改部件类型信息
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateAssemTypeInfo(AssemTypeUpdateCommand m)
        {
            return await _mediator.Send(m);
        }

        /// <summary>
        /// 单个逻辑删除部件类型信息
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> FalseDeleteAssemTypeInfo([FromQuery]AssemTypeFalseDeleteCommand m)
        {
            return await _mediator.Send(m);
        }
    }
}
